From 3c9f8469ed8f70db9d12e738c65c2f4d4b2dcf38 Mon Sep 17 00:00:00 2001 From: "atse@norwich.uk.xensource.com" Date: Thu, 28 Sep 2006 12:16:11 +0100 Subject: [PATCH] [XM] Fix error reporting for resources.py, remove duplicate try block. Also fixed usage message to not include misspelling of the command. Signed-off-by: Alastair Tse --- tools/python/xen/xm/resources.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tools/python/xen/xm/resources.py b/tools/python/xen/xm/resources.py index c0ddeb5560..52db568501 100644 --- a/tools/python/xen/xm/resources.py +++ b/tools/python/xen/xm/resources.py @@ -24,7 +24,7 @@ from xen.util import security from xen.xm.opts import OptionError def help(): - return """Usage: xm resource + return """ This program lists information for each resource in the global resource label file.""" @@ -45,18 +45,13 @@ def main (argv): filename = security.res_label_filename access_control = dictio.dict_read("resources", filename) except: - print "Resource file not found." - return + raise OptionError("Resource file not found") - try: - file = security.res_label_filename - access_control = dictio.dict_read("resources", file) - except: - security.err("Error reading resource file.") - - print_resource_data(access_control) + print_resource_data(access_control) if __name__ == '__main__': - main(sys.argv) - - + try: + main(sys.argv) + except Exception, e: + sys.stderr.write('Error: %s\n' % str(e)) + sys.exit(-1) -- 2.30.2